package com.fxp.project.jiuselu.web.business.v1.controller.logistic;

import com.fxp.project.jiuselu.web.base.controller.BaseController;
import com.fxp.project.jiuselu.web.business.v1.request.cart.ReqLogistic;
import com.fxp.project.jiuselu.web.domain.CommonResult;
import com.fxp.project.jiuselu.web.models.order.service.IJslLogisticAreaService;
import com.fxp.project.jiuselu.web.models.order.vo.JslLogisticAreaVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/v1/logistic")
public class LogisticAreaController extends BaseController {
    @Autowired
    IJslLogisticAreaService jslLogisticAreaService;

    /**
     * info: 根据当前的运费模板Id与区域Id获取信息<br/>
     *
     * @param reqLogistic
     * @param result
     * @return
     * @author Jason.Wang
     * @date 2022/1/27 14:57
     */
    @PostMapping("info")
    @CrossOrigin
    public CommonResult<JslLogisticAreaVo> info(@RequestBody @Validated ReqLogistic reqLogistic, BindingResult result) {
        super.checkBindResult(result);
        JslLogisticAreaVo jslLogisticAreaVo =
            jslLogisticAreaService.selectJslLogisticAreaVoByLogisticIdWithAreaId(reqLogistic.getGoodsId(),reqLogistic.getLogisticId(),
                reqLogistic.getAreaId(),reqLogistic.getAttrWeight(),reqLogistic.getType());
        return CommonResult.success(jslLogisticAreaVo);
    }
}
